home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_01
/
1001094b
< prev
next >
Wrap
Text File
|
1991-11-16
|
421b
|
30 lines
Listing 2
//
// test1.cpp
//
#include <stdio.h>
#include "rational.h"
int main()
{
int i;
rational r1 (1, 2); // r1 = 1/2;
rational r2 (3, 5); // r2 = 3/5;
for (i = 0; i < 3; ++i)
{
printf("r1 = ");
r1.put(stdout);
putchar('\n');
printf("r2 = ");
r2.put(stdout);
putchar('\n');
r1 = (r1 + r2) / rational(1, 2);
r2 = r2 * rational(2, 3) + r1;
}
return 0;
}